public class Main {

    //五子棋和棋问题

    public static int ans  = 0;
    public static void main(String[] args) {
        //棋盘大小为 5 * 5，这里使用二进制枚举
        int S = 1 << 25;
        for (int i = 0; i < S; i++) {
            //将白棋看做 1 ，黑棋看做 0
            int cnt0 = 0;
            int cnt1 = 0;
            for (int j = 0; j < 25; j++) {
                if(((i >> j) & 1) == 1){
                    cnt1 += 1;
                }else{
                    cnt0 += 1;
                }
            }

            if(cnt1 == 13 && cnt0 == 12){
                //此时棋盘下满
                //检查棋盘是否为和棋
                if(check(i)){
                    ans++;
                }
            }
        }
        System.out.println(ans);
    }

    private static boolean check(int st) {
        int[][] map = new int[6][6];
        int pos = 0;
        for (int i = 1; i <= 5 ; i++) {
            for (int j = 1; j <= 5; j++) {
                map[i][j] = ((st >> pos) & 1);
                pos++;
            }
        }

        //判断行
        int cnt0 = 0;
        int cnt1 = 0;
        for (int i = 1; i <= 5 ; i++) {
            cnt0 = 0;
            cnt1 = 0;
            for (int j = 1; j <= 5 ; j++) {
                if(map[i][j] == 0){
                    cnt0 += 1;
                }else{
                    cnt1 += 1;
                }
            }
            if(cnt1 == 5 || cnt0 == 5){
                return false;
            }
        }

        //判断列
        for (int i = 1; i <= 5 ; i++) {
            cnt0 = 0;
            cnt1 = 0;
            for (int j = 1; j <= 5 ; j++) {
                if(map[j][i] == 0){
                    cnt0 += 1;
                }else{
                    cnt1 += 1;
                }
            }
            if(cnt1 == 5 || cnt0 == 5){
                return false;
            }
        }

        //判断对角线
        cnt0 = 0;
        cnt1 = 0;
        for (int i = 1; i <= 5 ; i++) {
            if(map[i][i] == 0){
                cnt0 += 1;
            }else{
                cnt1 += 1;
            }
        }
        if(cnt1 == 5 || cnt0 == 5){
            return false;
        }
        cnt0 = 0;
        cnt1 = 0;
        for (int i = 1; i <= 5 ; i++) {
            if(map[i][6 - i] == 0){
                cnt0 += 1;
            }else{
                cnt1 += 1;
            }
        }
        if(cnt1 == 5 || cnt0 == 5){
            return false;
        }
        return true;
    }
}
